package com.ipt.frm.pw.filter;

import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;

import com.ipt.frm.pw.Mensaje;
import com.ipt.frm.pw.Tipo;

public class CheckFilter extends FiltroMaestro {

	private FilterConfig filterConfig;

	@Override
	public void doFilter(final ServletRequest request,
			final ServletResponse response, FilterChain chain)
			throws java.io.IOException, javax.servlet.ServletException {
		System.out.println("Entering CheckFilter");

		if (request.getAttribute("username") == null) {

			request.setAttribute("MSG", new Mensaje(Tipo.INFO,
					"No puede visualizar esta pagina sin estar logeado"));

			request.getRequestDispatcher("login").forward(request, response);
		}
		chain.doFilter(request, response);
		System.out.println("Exiting CheckFilter");
	}
}
